package br.com.projeto.Adapter;

import java.util.List;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;
import br.com.clientes.R;
import br.com.projeto.VO.ClienteVO;

public class ClienteAdapter extends BaseAdapter {

	private List<ClienteVO> lista;
	private Context ctx;

	public ClienteAdapter(Context ctx, List<ClienteVO> lista) {
		// TODO Auto-generated constructor stub
		this.ctx = ctx;
		this.lista = lista;
	}

	@Override
	public int getCount() {
		return lista.size();
	}

	@Override
	public Object getItem(int position) {
		return lista.get(position);
	}

	@Override
	public long getItemId(int position) {
		return position;
	}

	@Override
	public View getView(int position, View view, ViewGroup viewGroup) {
		ClienteVO cliente = (ClienteVO) getItem(position);

		LayoutInflater layout = (LayoutInflater) ctx
				.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
		View v = layout.inflate(R.layout.listar, null);

		TextView txtID = (TextView) v.findViewById(R.id.txtListarID);
		txtID.setText(cliente.getId().toString());
		TextView txtNome = (TextView) v.findViewById(R.id.txtListarNome);
		txtNome.setText(cliente.getNome().toString());
		return v;
	}

}
